<template>
	<view class="content">
		<SideEdge :Dataindex='3'></SideEdge>
		<view class="right">
			<search></search>
			<view class="title">
				<text>学科错题</text>
				<view class="backdrop"></view>
			</view>
			<view class="third">
				<view class="item" v-for="(item,index) in list" :key="index">
					<image class="cover" :src="item.logo" mode=""></image>
					<view class="linbox">
						<view class="information">
							<view class="infoLine">
								<text class="title">{{item.title}}</text>
								<view class="Number" :class="{No1: index == 0,No2: index == 1,No3: index == 2}">
									No.{{index + 1}}
								</view>
							</view>
							<text class="substring">{{item.desc}}</text>
						</view>
						<view class="btnBox">
							<view hover-class="checkActive" hover-stay-time='20' class="btn" @click="onclick(item)">学 习
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		subjectList,
		wrongQuestion
	} from '@/common/api/subject.js'

	function onclick(item) {
		wrongQuestion({
			subject_id: item.id
		}).then(res => {
			if (res.code == 1) {
				uni.navigateTo({
					url: `/pages/index/WrongQuestion?subject_id=${item.id}`
				})
			}
		})
	}

	import {
		ref
	} from "vue"
	const list = ref([])

	function subjectData() {
		list.value = []
		subjectList().then(res => list.value = res.data)
	}
	subjectData()

	import {
		onShow
	} from "@dcloudio/uni-app"; // 该依赖已内置不需要单独安装
	onShow(() => {
		uni.hideTabBar()
		subjectData()
	})
</script>

<style>
	page {
		width: 100%;
		height: auto;
		background: #F7F7F7;
		overflow-x: hidden;
	}
</style>

<style lang="scss" scoped>
	.content {
		width: 100vw;
		height: 100vh;
		display: flex;
		align-items: center;
		position: relative;
	}

	.right {
		width: calc(100vw - 300px);
		height: 100vh;
		overflow: overlay;

		.title {
			position: relative;
			margin-left: 20 * 0.8px;
			margin-top: 20 * 0.8px;

			text {
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				font-size: 32px;
				color: #040404;
				line-height: 34px;
				text-align: left;
				font-style: normal;
				position: relative;
				z-index: 999;
			}

			.backdrop {
				width: 127px;
				position: relative;
				bottom: 15px;
				height: 15px;
				background: #2283E2;
			}
		}

		.third {
			max-height: calc(100vh - 140px - 70px);
			overflow: overlay;
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			justify-content: flex-start;
			margin: 0 20 * 0.8px;
			gap: 8px;

			.item {
				background: #FFFFFF;
				border-radius: 12px;
				padding: 20rpx 20rpx 0;
				padding-bottom: 10px;

				.cover {
					width: 430 * 0.8px;
					height: 186 * 0.8px;
				}

				.linbox {
					margin-top: 30 * 0.8px;
					margin-top: 24px;
					display: flex;
					align-items: center;
					justify-content: space-between;

					.information {
						display: flex;
						flex-direction: column;
						align-items: flex-start;

						.infoLine {
							display: flex;
							align-items: center;

							.title {
								margin: 0;
								margin-right: 8px;
								font-family: PingFangSC, PingFang SC;
								font-weight: 600;
								font-size: 28rpx;
								color: #040404;
							}

							.Number {
								width: 49px;
								height: 22px;
								background: #787774;
								border-radius: 6px;

								display: flex;
								align-items: center;
								justify-content: center;

								font-family: PingFangSC, PingFang SC;
								font-weight: 600;
								font-size: 14px;
								color: #FFFFFF;

							}

							.No1 {
								background: #FE3D39;
							}

							.No2 {
								background: #2283E2;
							}

							.No3 {
								background: #FFB600;
							}
						}

						.substring {
							margin-top: 10px;
							font-family: PingFangSC, PingFang SC;
							font-weight: 400;
							font-size: 16rpx;
							color: #B2B1AF;
						}
					}

					.btnBox {
						display: flex;

						.btn {
							width: 100 * 0.8px;
							height: 52 * 0.8px;
							background: #141414;
							border-radius: 12 * 0.8px;
							font-family: PingFangSC, PingFang SC;
							font-weight: 600 * 0.8;
							font-size: 20 * 0.8px;
							color: #FFFFFF;
							line-height: 18 * 0.8px;
							display: flex;
							align-items: center;
							justify-content: center;
						}
					}
				}
			}
		}
	}
</style>